<#assign import_block>
import { Watch } from 'vue-property-decorator';
</#assign>
<#assign self_content>
    /**
     * 分割宽度
     *
     * @type {string}
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public split: string = '260px';

    /**
     * 树导航栏数据
     *
     * @type {any}
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public wfStepModel: Array<any> = [];

    /**
     * 是否展开搜索表单
     *
     * @type {any}
     * @memberof  ${srfclassname('${view.codeName}')}Base
     */
    public isExpandSearchForm:boolean = <#if view.isExpandSearchForm()>true<#else>false</#if>;

    /**
     * 是否单选
     *
     * @type {any}
     * @memberof  ${srfclassname('${view.codeName}')}Base
     */
    public isGridSingleSelect:boolean = true;

    /**
     * 左侧树的默认配置
     *
     * @type {any}
     * @memberof  ${srfclassname('${view.codeName}')}Base
     */
    public defaultProps:any ={
         children: 'children',
         label: 'userTaskName'
    };

    /**
     * 左侧树当前选中节点
     *
     * @type {any}
     * @memberof  ${srfclassname('${view.codeName}')}Base
     */
    public curSelectedNode:any;

    /**
     * 获取树导航栏数据
     *
     * @memberof  ${srfclassname('${view.codeName}')}Base
     */
    public getWFStepModel():Promise<any>{
        return new Promise((resolve:any, reject:any) =>{
            this.appEntityService.WFGetWFStep().then((response:any) =>{
                if (response && response.status === 200) {
                    this.wfStepModel = response.data;
                    if(this.wfStepModel && this.wfStepModel.length > 0){
                        if(!this.curSelectedNode){
                            this.curSelectedNode = this.wfStepModel[0];
                        }else{
                            let tempCopySelectedNode:any = this.$util.deepCopy(this.curSelectedNode);
                            this.curSelectedNode = this.wfStepModel.find((item:any) =>{
                                return item.userTaskId === tempCopySelectedNode.userTaskId && item.processDefinitionKey === tempCopySelectedNode.processDefinitionKey;
                            })
                        }
                    }
                    if(this.curSelectedNode) {
                        Object.assign(this.viewparams,{'userTaskId':this.curSelectedNode['userTaskId'],'processDefinitionKey':this.curSelectedNode['processDefinitionKey']});
                        this.setTreeNodeHighLight(this.curSelectedNode);
                    }
                    resolve(response.data);
                }
                }).catch((response: any) => {
                    if (response && response.status) {
                        this.$Notice.error({ title: '错误', desc: response.message });
                        return;
                    }
                    if (!response || !response.status || !response.data) {
                        this.$Notice.error({ title: '错误', desc: '系统异常' });
                        return;
                    }
                });
        })
    }

    /**
     * 左侧树选中节点
     *
     * @type {any}
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public handleNodeClick(data:any) {
        this.curSelectedNode = data;
        this.setTreeNodeHighLight(this.curSelectedNode);
        Object.assign(this.viewparams,{'userTaskId':data['userTaskId'],'processDefinitionKey':data['processDefinitionKey']});
        if(this.$refs.searchform) {
            (this.$refs.searchform as any).onSearch();
        }
    }

    /**
     * 设置选中高亮
     *
     * @param {*} data
     * @memberof ${srfclassname('${view.codeName}')}Base
     */
    public setTreeNodeHighLight(data: any): void {
        this.$nextTick(() =>{
            const tree: any = this.$refs.tree;
            if(tree) {
                tree.setCurrentKey(data.userTaskId);
            }
        })
    }
<#if view.hasPSControl('grid')>
<#assign grid = view.getPSControl('grid')>

    /**
     * 刷新数据
     *
     * @readonly
     * @type {(number | null)}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    get refreshdata(): number | null {
        return this.$store.getters['viewaction/getRefreshData'](this.viewtag);
    }

    /**
     * 监控数据变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @returns
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Watch('refreshdata')
    onRefreshData(newVal: any, oldVal: any) {
        if (newVal === null || newVal === undefined) {
            return;
        }
        if (newVal === 0) {
            return;
        }
        const grid: any = this.$refs.${grid.name};
        if (grid) {
            grid.load({});
        }
    }
</#if>
</#assign>
<#ibizinclude>
../@MACRO/VIEW-BASE.vue.ftl
</#ibizinclude>